package com.basker.pisces.domain.entity.data;

import java.util.List;

import org.springframework.lang.Nullable;

import com.basker.pisces.core.PageRowList;
import com.basker.pisces.core.RowContract;
import com.basker.pisces.core.query.IQuery.PagingInfo;
import com.basker.pisces.core.query.QueryInfo;
import com.basker.pisces.core.query.builder.CriterionBuilder;
import com.basker.pisces.core.query.builder.CriterionBuilder.Operator;
import com.basker.pisces.core.query.criteria.Criterion;
import com.basker.pisces.domain.annotation.PropertyOutput;
import com.basker.pisces.domain.entity.meta.Entity;

public interface IRowListDataEntity {

    /**
     * 添加条件
     *
     * @param criterion
     * @see CriterionBuilder#create(String, Operator, Object)
     * @see CriterionBuilder#create(String, String, Object)
     */
    void addCriterion(Criterion criterion);

    /**
     * 对应的实体对象
     *
     * @return
     */
    Entity getEntity();

    /**
     * 将rowList填充到outputType对应的对象中
     *
     * @param <T>
     * @param rowList
     * @param outputType 一个pojo类型,字段通过{@link PropertyOutput}与rowList的属性绑定
     * @return
     */
    <T> List<T> output(List<RowContract> rowList, Class<T> outputType);

    /**
     * 列表查询
     *
     * @param queryInfo  详细的查询信息，包括需要查询的字段、条件、排序
     * @param pagingInfo 不想分页的话可以传入null或者{@link PagingInfo#NO_PAGING}
     * @return
     */
    PageRowList query(QueryInfo queryInfo, @Nullable PagingInfo pagingInfo);

}
